package com.netctoss.admin.action;

import com.netctoss.DAOFactory;
import com.netctoss.admin.dao.IAdminDAO;
import com.netctoss.exception.DAOException;
import com.netctoss.login.entity.Admin;

public class AddAdminAction {
	private Admin admin;
	private Admin a;
	
	public String execute(){
		IAdminDAO dao = DAOFactory.getAdminDAO();
		try {
			dao.addAdmin(admin);
			a = dao.findByAdminCode(admin.getAdminCode());
			dao.addAdminRoles(admin,a.getId());
		} catch (DAOException e) {
			e.printStackTrace();
			return "erroe";
		}
		return "success";
	}
	
	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}
	
}
